﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminFunction.Master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="BitPortal.Admin.Product.Category.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .bold-text
        {
            font-weight: bold;
            padding-left: 25px;
            font-size: 110%;
        }
    </style>
    <style type="text/css">
        .x-form-group .x-form-group-header-text
        {
            background-color: #dfe8f6;
        }
        
        .x-label-text
        {
            font-weight: bold;
            font-size: 11px;
        }
    </style>
    <script type="text/javascript">
        function showMenu(node, e) {
            var menu = <%=TreeContextMenu.ClientID %>;
            if (node.browserEvent) {
                this.menuNode = this.getRootNode();
                menu.nodeName = "";
                this.getSelectionModel().clearSelections();
                e = node;
            }
            else {
                this.menuNode = node;
                menu.nodeName = node.text;
                node.select();
            }

            menu.showAt([e.getXY()[0], e.getXY()[1] + 18]);
            e.stopEvent();
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ext:Menu ID="TreeContextMenu" runat="server" EnableScrolling="false">
        <Items>
            <ext:MenuTextItem ID="NodeName" runat="server" Cls="bold-text" />
            <ext:MenuSeparator />
            <ext:MenuItem ID="MenuItem1" runat="server" Text="Rename" Icon="Pencil">
                <Listeners>
                    <Click Handler="#{TreePanel1}.startEdit(#{TreePanel1}.menuNode, 10);" />
                </Listeners>
            </ext:MenuItem>
            <ext:MenuItem ID="MenuItem2" runat="server" Text="Remove" Icon="Delete">
                <Listeners>
                    <Click Handler="#{TreePanel1}.removeNode(#{TreePanel1}.menuNode);" />
                </Listeners>
            </ext:MenuItem>
            <ext:MenuItem ID="MenuItem3" runat="server" Text="Append child" Icon="Add">
                <Listeners>
                    <Click Handler="#{TreePanel1}.appendChild(#{TreePanel1}.menuNode, 'New');" />
                </Listeners>
            </ext:MenuItem>
            <ext:MenuItem ID="MenuItem4" runat="server" Text="Insert child" Icon="ArrowRight">
                <Listeners>
                    <Click Handler="#{TreePanel1}.appendChild(#{TreePanel1}.menuNode, 'New', true);" />
                </Listeners>
            </ext:MenuItem>
            <ext:MenuItem ID="MenuItem5" runat="server" Text="Sửa chi tiết" Icon="BulletEdit">
                <DirectEvents>
                    <Click OnEvent="SubmitNode">
                        <ExtraParams>
                            <ext:Parameter Name="node" Value="#{TreePanel1}.convertToSubmitNode(#{TreePanel1}.getSelectionModel().getSelectedNode())"
                                Mode="Raw" Encode="true" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:MenuItem>
        </Items>
        <Listeners>
            <Show Handler="#{NodeName}.el.update(this.nodeName);" />
        </Listeners>
    </ext:Menu>
    <ext:TreePanel ID="TreePanel1" runat="server" AnchorVertical="100%" Title="Danh sách nhóm sản phẩm"
        Mode="Remote" OnRemoteAppend="TreePanel1_RemoteAppend" OnRemoteRemove="TreePanel1_RemoteRemove"
        OnRemoteRename="TreePanel1_RemoteRename" Padding="20" EnableDD="true" OnRemoteMove="TreePanel1_RemoteMove">
        <Editors>
            <ext:TreeEditor ID="TreeEditor1" runat="server" CancelOnBlur="true">
                <Field>
                    <ext:TextField ID="TextField1" runat="server" />
                </Field>
            </ext:TreeEditor>
        </Editors>
        <SelectionSubmitConfig Encode="true" WithChildren="true" />
        <Listeners>
            <ContextMenu Fn="showMenu" StopEvent="true" />
        </Listeners>
        <BottomBar>
            <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>
                    <ext:SplitButton runat="server" ID="btnTrash" Text="Thùng rác" Icon="Bin">
                        <Menu>
                            <ext:Menu ID="Menu2" runat="server">
                                <Items>
                                    <ext:MenuItem ID="MenuItem8" runat="server" Text="Xóa tất cả" Icon="Cancel">
                                        <DirectEvents>
                                            <Click OnEvent="btnTrashEmpty_Click">
                                                <EventMask ShowMask="true" Msg="Đang thực hiện..." MinDelay="500" />
                                            </Click>
                                        </DirectEvents>
                                    </ext:MenuItem>
                                    <ext:MenuItem ID="MenuItem9" runat="server" Text="Xóa nhóm được chọn" Icon="BinEmpty">
                                        <DirectEvents>
                                            <Click OnEvent="btnTrashDelete_Click">
                                                <EventMask ShowMask="true" Msg="Đang thực hiện..." MinDelay="500" />
                                            </Click>
                                        </DirectEvents>
                                    </ext:MenuItem>
                                    <ext:MenuItem ID="MenuItem10" runat="server" Text="Bỏ khỏi thùng rác" Icon="ArrowTurnLeft">
                                        <DirectEvents>
                                            <Click OnEvent="btnUnDelete_Click">
                                                <EventMask ShowMask="true" Msg="Đang thực hiện..." MinDelay="500" />
                                            </Click>
                                        </DirectEvents>
                                    </ext:MenuItem>
                                </Items>
                            </ext:Menu>
                        </Menu>
                        <DirectEvents>
                        </DirectEvents>
                        <Listeners>
                            <Click Handler="#{Window2}.show();#{GridPanel1}.getStore().reload();" />
                        </Listeners>
                    </ext:SplitButton>
                </Items>
            </ext:Toolbar>
        </BottomBar>
    </ext:TreePanel>
    <ext:Window ID="Window1" runat="server" Collapsible="true" Height="600" Icon="ApplicationEdit"
        Title="Title" Width="650" Layout="FormLayout" Padding="10" Modal="true" AutoScroll="true"
        Hidden="true" AutoHeight="true">
        <Items>
            <ext:Hidden Text="0" runat="server" ID="txtCategoryID">
            </ext:Hidden>
            <ext:TextField ID="txtName" runat="server" FieldLabel="Tên nhóm" EmptyText="Nhập tên nhóm"
                AllowBlank="false" AnchorHorizontal="100%" />
            <ext:HtmlEditor ID="txtDescription" runat="server" AnchorHorizontal="100%" FieldLabel="Mô tả"
                Height="200">
            </ext:HtmlEditor>
            <ext:NumberField ID="txtSortOrder" runat="server" AllowBlank="false" AllowDecimals="false"
                MinValue="0" FieldLabel="Thứ tự">
            </ext:NumberField>
            <ext:Checkbox ID="ckAllowUserPost" runat="server" FieldLabel="Cho phép thành viên gửi sản phẩm"
                LabelAlign="Top">
            </ext:Checkbox>
            <ext:Checkbox ID="ckEnabled" runat="server" FieldLabel="Hiển thị" LabelAlign="Right">
            </ext:Checkbox>
            <ext:Checkbox ID="ckEnabledThumbnail" runat="server" FieldLabel="Hiển thị ảnh đại diện"
                LabelAlign="Right">
            </ext:Checkbox>
            <ext:FileUploadField ID="txtThumbnail" runat="server" FieldLabel="Hình đại diện"
                Width="440">
            </ext:FileUploadField>
            <ext:Panel ID="Meta" runat="server" FormGroup="true" Title="Cấu hình SEO - Thẻ meta"
                Collapsed="true" Padding="10">
                <Content>
                    <ext:TextField ID="txtMetaTitle" runat="server" FieldLabel="Thẻ meta title" EmptyText="Thẻ meta title"
                        AllowBlank="true" Width="440" />
                    <ext:TextArea ID="txtMetaKeyword" runat="server" FieldLabel="Thẻ từ khóa" EmptyText="Nhập từ khóa"
                        Width="440">
                    </ext:TextArea>
                    <ext:TextArea ID="txtMetaDescription" runat="server" FieldLabel="Thẻ mô tả" EmptyText="Nhập mô tả"
                        Width="440">
                    </ext:TextArea>
                </Content>
            </ext:Panel>
        </Items>
        <Buttons>
            <ext:Button ID="btnUpdate" runat="server" Text="Cập nhật">
                <DirectEvents>
                    <Click OnEvent="btnUpdate_Click">
                        <EventMask ShowMask="true" Msg="Saving..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button ID="btnCancel" runat="server" Text="Bỏ qua">
                <Listeners>
                    <Click Handler="#{Window1}.hide();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    <ext:Store ID="Store1" runat="server" OnRefreshData="Store1_RefreshData">
        <Reader>
            <ext:JsonReader IDProperty="CategoryID">
                <Fields>
                    <ext:RecordField Name="Name" Type="String" />
                    <ext:RecordField Name="CategoryID" Type="Int" />
                    <ext:RecordField Name="ParentID" Type="Auto" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <SortInfo Field="CategoryID" Direction="ASC" />
    </ext:Store>
    <ext:Window ID="Window2" runat="server" Collapsible="true" Height="600" Icon="BinClosed"
        Title="Thùng rác" Width="650" Padding="10" Modal="false" AutoScroll="true" Hidden="true"
        AutoHeight="true">
        <Items>
            <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" Title="Danh mục sản phẩm"
                StoreID="Store1">
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column Header="Mã" DataIndex="CategoryID" Width="100" />
                        <ext:Column Header="Tên danh mục" DataIndex="Name" />
                        <ext:Column Header="Danh mục cha" DataIndex="ParentID" Width="100" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" />
                </SelectionModel>
                <LoadMask ShowMask="true" />
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="20" />
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:Window>
</asp:Content>
